home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 3d_lib.zip / NF.C < prev    next >
C/C++ Source or Header  |  1993-05-09  |  1KB  |  59 lines

  1. /* Create new face
  2.  
  3.    Copyright (c) 1988 by Gus O'Donnell
  4.  
  5.    Revision history:
  6.  
  7.    Version 1.00         February 29, 1988       As released.
  8.  
  9.    Version 1.01         March 20, 1988          Created libraries for all
  10.                                                 memory models
  11.  
  12. */
  13. #include "3d.h"
  14. #include <alloc.h>
  15. #include <float.h>
  16. #include <math.h>
  17. #include <stdio.h>
  18.  
  19. int     new_face (FACE *this_face)
  20.  
  21. /* Create a new face.  The initial data structure looks like this:
  22.  
  23.  
  24.                FACE o X
  25.                     |
  26.                     |
  27.                     V
  28.                  CORNER o X
  29.                         |
  30.                     +---+
  31.                     |
  32.                     V
  33.                  CORNER X X
  34.  
  35. Where 'X' is the NULL pointer.
  36.  
  37. The function returns an integer status as follows:
  38.  
  39.              0 - operation successful
  40.              1 - cannot allocate memory
  41. */
  42.  
  43. {
  44.     CORNER *chandle1,*chandle2;     /* Handles for head and tail nodes of
  45.                                        CORNER list */
  46.  
  47.     /* Allocate memory.  Return a 1 if unsuccessful. */
  48.  
  49.     if (!(chandle1 = (CORNER *)malloc(sizeof(CORNER)))) return(1);
  50.     if (!(chandle2 = (CORNER *)malloc(sizeof(CORNER)))) return(1);
  51.     this_face -> first = chandle1;
  52.     this_face -> next = NULL;
  53.     chandle1 -> this = NULL;
  54.     chandle1 -> next = chandle2;
  55.     chandle2 -> this = NULL;
  56.     chandle2 -> next = NULL;
  57.     return(0);
  58. }
  59.